﻿using System;

namespace Clock
{
    public delegate void Hint();


    class Clock
    {
        public System.DateTime time;
        public event Hint Alarm,Dida;
        public void settime()
        {
            int x = 0;
            Console.WriteLine(System.DateTime.Now.ToShortDateString() + "请输入多少毫秒后闹钟响铃：");
            time = new DateTime();
            time = System.DateTime.Now;
            x=int.Parse(Console.ReadLine().Trim());
            time=time.AddSeconds(x);
        }
        public void Ifring()
        {
            do
            {
                System.Threading.Thread.Sleep(1000);
                Dida();
                Console.WriteLine(time.Second-System.DateTime.Now.Second);
                
            }
            while(time.Second>System.DateTime.Now.Second);
            {
                Ring();
                Alarm();
            }
        }
        private void Ring()
        {
            Console.WriteLine("ding~");
        }
        

    }
    class Man
    {
        public void setAlram()
        {
            Console.WriteLine("设置的闹钟响铃");
        }
        public void setDida()
        {
            Console.WriteLine("设置闹钟dida");
        }
    }
    class Text
    {
        public static void Main(String[] args)
        {
            Clock clock = new Clock();
            Man man = new Man();
            Hint hint = null;
            /*hint = new Hint(man.setAlram);*/
            clock.Alarm += new Hint(man.setAlram);
            clock.Dida+=new Hint(man.setDida);
            clock.settime();
            clock.Ifring();

        }
    }

}
